#include <bits/stdc++.h>
using namespace std;

class Solution
{
public:
    int main()
    {
        vector<int> nums;
        nums.reserve(100);
        int num = -1;
        while (true)
        {
            cin >> num;
            if (num != 0)
            {
                nums.push_back(num);
            }
            else
            {
                break;
            }
        }
        for (auto it = nums.rbegin(); it != nums.rend(); ++it)
        {
            cout << *it << " ";
        }
        return 0;
    }
};

#ifndef __LOCAL_TEST__
int main()
{
    return Solution().main();
}
#endif